<template>
  <div class="layout-container">
    <el-container>
      <!-- 侧边栏 -->
      <el-aside width="200px" style="background-color: #545c64;height: 100%;" >
        <el-menu
        default-active="2"
        class="el-menu-vertical-demo"
        @open="handleOpen"
        @close="handleClose"
        background-color="#545c64"
        text-color="#fff"
        active-text-color="#ffd04b"
        router>
          <el-submenu index="1">
            <template slot="title">
              <i class="el-icon-location"></i>
              <span>内容管理</span>
            </template>
            <el-menu-item-group>
              <el-menu-item index="/admin/personalWork">个人作品</el-menu-item>
              <el-menu-item index="1-2">个人总结</el-menu-item>
              <el-menu-item index="1-2">学习记录</el-menu-item>
            </el-menu-item-group>
          </el-submenu>
          <el-submenu index="2">
            <template slot="title">
              <i class="el-icon-location"></i>
              <span>页面管理</span>
            </template>
            <el-menu-item-group>
              <el-menu-item index="/admin/swiper">图片管理</el-menu-item>
              <el-menu-item index="/admin/quotes">名言管理</el-menu-item>
            </el-menu-item-group>
          </el-submenu>
          <el-submenu index="3">
            <template slot="title">
              <i class="el-icon-location"></i>
              <span>信息管理</span>
            </template>
            <el-menu-item-group>
              <el-menu-item index="/admin/user">用户管理</el-menu-item>
              <el-menu-item index="/admin/admin">管理员管理</el-menu-item>
            </el-menu-item-group>
          </el-submenu>
        </el-menu>
      </el-aside>
      <el-container>
        <!-- 头部导航 -->
        <el-header>
          <div class="logout">
            <span style="font-size: 40px;color: aliceblue;">当前管理员:{{adminname}}</span>
            <button class="logout-btn" @click="logout">注销</button>
          </div>
        </el-header>
        <!-- 内容区域 -->
        <el-main>
          <router-view></router-view>
        </el-main>
        <!-- 页脚 -->
        <el-footer>Footer

        </el-footer>
      </el-container>
    </el-container>
  </div>
</template>

<script>
export default {
  data() {
    return {
      adminname:localStorage.getItem('username')
    }
  },
  methods: {
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },
    logout() {
      localStorage.clear()
      this.$router.push('/home')
    }
  }
}
</script>

<style scoped>
* {
  margin: 0;
  padding: 0;
}
.layout-container {
  width: 100%;
  height: 100%;
}
.el-container{
  width: 100%;
  height: 100%;
}
.el-header {
  background-color: #545c64;
}
.logout,.logout-btn {
  height: 100%;
}
.logout-btn {
  width: 60px;
  height: 40px;
  margin-top: 10px;
  border: 0;
  border-radius: 20%;
  outline: none;
  float: right;
}
.logout-btn:hover {
   box-shadow: 0 0 7px rgb(240, 220, 220);
 }
 .el-footer {
   background-color: #fff;
 }
</style>